package com.jams.goodox.entity.resp;

import com.jams.goodox.entity.AnnexBean;
import com.jams.goodox.entity.FastCarOrder;
import com.jams.goodox.entity.Mapper;
import com.jams.goodox.entity.PageInfo;
import com.jams.goodox.net.BaseEntity;

import java.util.ArrayList;
import java.util.List;

/**
 * 好司机带带我首页列表
 * Created by guozhen.hou on 2017/6/14.
 */

public class FastCarListResp extends BaseEntity{

    private DataBean data;

    public DataBean getData() {
        return data;
    }

    public void setData(DataBean data) {
        this.data = data;
    }

    public static class DataBean implements Mapper<List<FastCarOrder>>{
        private PageInfo pageInfo;
        private List<ResultListBean> resultList;
        private boolean flag;
        private boolean isFareOrder;

        public boolean isFlag() {
            return flag;
        }

        public void setFlag(boolean flag) {
            this.flag = flag;
        }

        public PageInfo getPageInfo() {
            return pageInfo;
        }

        public void setPageInfo(PageInfo pageInfo) {
            this.pageInfo = pageInfo;
        }

        public List<ResultListBean> getResultList() {
            return resultList;
        }

        public void setResultList(List<ResultListBean> resultList) {
            this.resultList = resultList;
        }

        @Override
        public List<FastCarOrder> transform() {
            List<FastCarOrder> list=new ArrayList<>();
            if(resultList!=null&&resultList.size()>0){
                for(ResultListBean resultListBean:resultList){
                    resultListBean.setIsFareOrder(isFareOrder);
                    list.add(resultListBean.transform());
                }
            }
            return list;
        }

        public void setIsFareOrder(boolean isFareOrder){
            this.isFareOrder=isFareOrder;
        }

        public static class ResultListBean implements Mapper<FastCarOrder>{
            private String depArrive;
            private String depLeave;
            private String depTime;
            private String headPicName;
            private String carId;
            private String payType;
            private String remunera;
            private String sex;
            private String tripsNum;
            private String userName;
            private List<AnnexBean> annexs;
            private String orderStatus;
            private String communityName;
            private String carNumber;
            private String mobileNum;
            private String ownerId;
            private String passengerId;
            private String enterpriseName;

            private boolean isFareOrder;
            public void setIsFareOrder(boolean isFareOrder){
                this.isFareOrder=isFareOrder;
            }

            @Override
            public FastCarOrder transform() {
                FastCarOrder fastCarOrder=new FastCarOrder();
                fastCarOrder.userImg=headPicName;
                fastCarOrder.isMan="1".equalsIgnoreCase(sex);
                fastCarOrder.userName=userName;
                fastCarOrder.dateTime=depTime;
                fastCarOrder.peopleNumber=(tripsNum==null?"0":tripsNum+"人");
                fastCarOrder.startPlace=depLeave;
                fastCarOrder.endPlace=depArrive;
                fastCarOrder.isPayMoney="1".equalsIgnoreCase(payType);
                fastCarOrder.annexBeanList = (annexs == null ? new ArrayList<AnnexBean>() : annexs);
                fastCarOrder.goodName=remunera;
                fastCarOrder.payMoney=remunera;
                fastCarOrder.isFareOrder=true;
                fastCarOrder.orderStatus=(orderStatus==null?"0":orderStatus);
                fastCarOrder.orderId=carId;
                fastCarOrder.isFareOrder=isFareOrder;
                fastCarOrder.communityName=communityName;
                fastCarOrder.carNum=carNumber;
                fastCarOrder.userPhone=mobileNum;
                fastCarOrder.toUserId=isFareOrder?ownerId:passengerId;
                fastCarOrder.enterpriseName=enterpriseName;
                return fastCarOrder;
            }
        }
    }

}
